<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:c="http://java.sun.com/jsp/jstl/core" 
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"> 

<h:head>
	<title>Cadastro de Usuários</title>
	<link rel="stylesheet" href="../../../resources/styles/layout.css" type="text/css"/>
	
</h:head>

<h:body>
	<h:form id="form1">
	<div class="wrapper row1">
	  <header id="header" class="clear">
	    <hgroup>
	      <h1><a href="index.html">Cardápio Mobile</a></h1>
	      <h2>Seu cardápio para o mundo todo </h2>
	    </hgroup>
			<fieldset class="fl_right">
		    	<p:panel style="width:300px;height:50px;right:200px;top:60px;background:#696969;border:1px solid black">  
			    	<h:outputLabel style="font-weight:bold;color:#FFFFE0;" value="Usuário:"/>
					<h:outputLabel style="font-weight:bold;color:#FFA500;" value="#{loginMB.getSessao('NomeUsuario')}"/>  
					<fieldset>		
						<h:outputLabel value="Restaurante:" style="font-weight:bold;color:#FFFFE0;"/>  
						<h:outputLabel style="font-weight:bold;color:#FFA500;" value="#{loginMB.getSessao('NomeFantasia')}"/>
					</fieldset>  
				</p:panel> 
			</fieldset>
			<fieldset>
			<p></p>
			</fieldset>
			
	    <nav class="clear">
	      <ul>
	        <li class="active"><a href="#">Minha Conta</a>
	          <ul>
	            <li><a href="portalCardapioMundo.jsf">Portal Home</a></li>
	            <li><a href="../user/meusDados.jsf">Meus Dados</a></li>
	            <li><a href="portalCardapioMundo.jsf?changeAccess=EEN013550">Trocar Acesso</a></li>
	            <li onclick="PF('dlgSair').show()"><a href="#">Sair</a></li>
	            <li><a href="#"></a></li>
	          </ul>
	        </li>
	
	        <li><a href="#">Acesso</a>
	          <ul>
	            <li><a href="../admin/cadUsuario.jsf">Novo Usuário</a></li>
	            <li><a href="../user/consUsuario.jsf">Consulta Usuários</a></li>
	            <li><a href="#"></a></li>
	          </ul>
	        </li>
	        
	        <li><a href="#">Restaurante</a>
	          <ul>
	            <li><a href="#">Novo Restaurante</a></li>
	            <li><a href="#">Restaurantes</a></li>
	            <li><a href="#"></a></li>
	          </ul>
	        </li>

	        <li><a href="#">Cardápio</a>
	          <ul>
	            <li><a href="#">Novo Cardápio</a></li>
	            <li><a href="#">Cardápios</a></li>
	            <li><a href="#"></a></li>
	          </ul>
	        </li>

	        <li><a href="#">Business Intelligence</a>
	          <ul>
	            <li><a href="#">Avaliações Cardápio</a></li>
	            <li><a href="#">Avaliações Atendimento</a></li>
	            <li><a href="#">Avaliações Infraestrutura</a></li>
	            <li><a href="#">Avaliação Geral</a></li>
	            <li><a href="#"></a></li>
	          </ul>
	        </li>

	        <li><a href="#">Pagamento</a>
	          <ul>
	            <li><a href="#">Meus Pagamentos</a></li>
	          </ul>
	        </li>
	        <li><a href="#">Plano</a>
	          <ul>
	            <li><a href="#">Meu Plano</a></li>
	            <li><a href="#">Renovação</a></li>
	            <li><a href="#">Novos Planos</a></li>
	          </ul>
	        </li>
	        
	      </ul>
	    </nav>
	  </header>
	</div>
	
	
	<p:dialog id="dialogSair" header="Opção Logout" modal="true" height="85" width="510" widgetVar="dlgSair" resizable="false" 
	showEffect="fade" hideEffect="fade">  
		<h:panelGrid columns="2" cellpadding="5">  
			<h:outputLabel for="username" value="Deseja desconectar do portal Cardápio Mobile ?" style="font-size:15px"/>
		</h:panelGrid>
				          
		<f:facet name="footer">  
			<p class="fl_left">
			<p:commandButton id="cancelarButton" value="Cancelar" height="50" width="50" onclick="PF(dlgSair).hide();"/>
			</p>
			<p class="fl_right">
				<p:commandButton id="sairButton" value="Sair" height="50" width="50" actionListener="#{acessoMB.logout}"/>
			</p>  
		</f:facet>  
    </p:dialog>
    </h:form>
	
	
	
	<!-- ########################################################################################## -->
	<h:form id="form2">
	<div class="wrapper row2">
	    <div id="container" class="clear"> 
	    <div id="homepage"> 
	    		<p:growl id="messages" showDetail="true"/>  
	    		<p:growl id="growl" showDetail="true"/>
  
			    <p:dataTable var="acessoPUsuario" value="#{acessoMB.usuarioDataModelL}" 
			    id="usuarioAcessosCAU" editable="true" paginator="true" rows="10">  
  
				        <f:facet name="header">  
				        </f:facet>  
				  
				        <p:ajax event="rowEdit" listener="#{acessoMB.onEdit}" update=":form2:messages" />  
				        <p:ajax event="rowEditCancel" listener="#{acessoMB.onCancel}" update=":form2:messages" />  

				        <p:column headerText="#{msgs.nomeUserCons}" style="width:10%">  
							<h:outputText value="#{acessoPUsuario.usuarioWeb.idUsuarioWeb}"  />  
				        </p:column>  
		  
				        <p:column headerText="#{msgs.nomeUserCons}" style="width:10%">  
							<h:outputText value="#{acessoPUsuario.usuarioWeb.nome}"  />  
				        </p:column>  
		
				        <p:column headerText="#{msgs.sobrenomeCons}" style="width:10%">  
							<h:outputText value="#{acessoPUsuario.usuarioWeb.sobrenome}"/> 
				        </p:column>  
		  
				        <p:column headerText="#{msgs.emailCons}" style="width:10%">  
				        	<h:outputText value="#{acessoPUsuario.usuarioWeb.mail}" />  
				        </p:column>  
				        
				        <p:column headerText="#{msgs.usernameCons}" style="width:10%">  
							<h:outputText value="#{acessoPUsuario.usuarioWeb.username}" />  
				        </p:column> 
				        
				        
				        <p:column headerText="#{msgs.acessoCons}" style="width:10%">  
					    	<p:cellEditor>  
								<f:facet name="output">  
									<h:outputText value="#{acessoPUsuario.restauranteWeb.nomeFantasia}" rendered="#{acessoPUsuario.acessoFilial == 'N'}"/>
									<h:outputText value="#{acessoPUsuario.restauranteFilialWeb.nomeFantasiaFilial}" rendered="#{acessoPUsuario.acessoFilial == 'S'}"/>
							    </f:facet>  
							    <f:facet name="input">  
							    	<h:selectOneMenu id="acessoRestaurante" value="#{acessoMB.idRestFilial}" style="width:100%">
						            	<f:selectItem itemLabel="Select One" itemValue=""/>
		
										  <f:selectItem itemValue="#{acessoMB.idRestaurante}" var="restaurante" itemLabel="#{acessoMB.nomeRestauranteSede}"/> 

											<f:selectItems value="#{acessoMB.tipoAcessoL}" var="acessoTipo" itemLabel="#{acessoTipo.restauranteFilialWeb.nomeFantasiaFilial}" 
											itemValue="#{acessoTipo.restauranteFilialWeb.idRestauranteFilialWeb}"/>  
											            
									</h:selectOneMenu>
							    </f:facet>  
							 </p:cellEditor>  
						</p:column>
						
				        <p:column headerText="#{msgs.perfilCons}" style="width:10%">  
				        	<h:outputText value="#{acessoPUsuario.perfil}"/>
				        </p:column>  
				        
				        <p:column headerText="#{msgs.statusCons}" style="width:10%">  
				            <p:cellEditor>  
				                <f:facet name="output">  
				                    <h:outputText value="Ativo" rendered="#{acessoPUsuario.status == 1}"/>
				                    <h:outputText value="Desativado" rendered="#{acessoPUsuario.status == 0}"/>
				                </f:facet>  
				                <f:facet name="input">  
				            		<h:selectOneMenu id="status" value="#{acessoMB.statusSelect}" style="width:100%" required="true">
			            				<f:selectItem itemLabel="Select One" itemValue=""/>
			            				<f:selectItem itemLabel="Ativo" itemValue="1"/>
			            				<f:selectItem itemLabel="Desativado" itemValue="0"/>
							        </h:selectOneMenu>
				                </f:facet>  
				            </p:cellEditor>  
				        </p:column>  
				          
				        <p:column style="width:4%">
				            <p:rowEditor />  
				        </p:column>
				        
				        <p:column style="width:4%">  
				            <p:commandButton id="selectButton" update=":form2:grid1" oncomplete="acessoDialog.show()" 
				            icon="ui-icon-search" title="Atribuir Acesso">  
		            			<f:setPropertyActionListener value="#{acessoPUsuario}" target="#{acessoMB.acesso}"/>  
		            		</p:commandButton>  
				        </p:column>  
		          
				</p:dataTable>
				
		    	<p:dialog id="dialog" header="Atribuir Novo Acesso" widgetVar="acessoDialog" resizable="false"  
		                showEffect="fade" hideEffect="explode" height="410" width="510" modal="true"
		                style="background-color:#FFF0F5;">  
		  
		  			<p:ajax event="close" update=":form2:novosAcessos"/> 
		  
		        	<p:panelGrid id="grid1" styleClass="ui-panelgrid"  columns="2">  
							<h:outputText value="#{acessoMB.acesso.usuarioWeb.username}" style="color: red;font-size:16px;font-weight:bold;"/>
					</p:panelGrid>

					<p:growl id="msgDialog" showDetail="true"/>
					
					<p:pickList id="novosAcessos" value="#{acessoMB.acessosPickView}"
				    	var="acessoUser"  effect="bounce" itemValue="#{acessoUser}" style="width:20%;"
				        converter="perfilAdmPickListConverter">
										 
						<f:facet name="sourceCaption">Restaurante/Filiais</f:facet>
						<f:facet name="targetCaption">Permissão Acesso</f:facet>
										
						<p:ajax event="transfer" listener="#{acessoMB.onTransferAcessos}" /> 
													 
						<p:column style="width:60%;" rendered="#{acessoUser.restauranteWeb != null}">  
				        	#{acessoUser.restauranteWeb.nomeFantasia} 
				        </p:column>
				        				
				        <p:column style="width:60%;" rendered="#{acessoUser.restauranteFilialWeb != null}">  
				        	#{acessoUser.restauranteFilialWeb.nomeFantasiaFilial} 
				        </p:column>
					</p:pickList>
			
			        
			        <p:panelGrid id="grid2" styleClass="ui-panelgrid2" columns="1" style="margin-bottom:0px;">  
		        	  <f:facet name="footer">	  
		        			<p class="fl_left">
		        				<p:commandButton  value="#{msgs.limpar}" icon="ui-icon-check" type="reset" immediate="true" update="novosAcessos">
		        				   <p:ajax update=":form2:novosAcessos"/> 
		        				</p:commandButton>
		        			</p>  
							<p class="fl_right">
								<p:commandButton  value="#{msgs.salvar}" icon="ui-icon-check" 
				        			action="#{acessoMB.salvarNovoAcesso}" update=":form2:msgDialog">

			            			<f:setPropertyActionListener value="#{acessoMB.acesso.usuarioWeb.idUsuarioWeb}" target="#{acessoMB.idUsuario}"/>

			        			</p:commandButton>  
							</p>
		    			</f:facet>
	    			</p:panelGrid>
			    </p:dialog>
      </div>
	  </div>
	</div>

	<!-- Copyright -->
	<div class="wrapper row4">
	  <footer id="copyright" class="clear">
	    <p class="fl_left">Copyright 2014 - All Rights Reserved - <a href="#">W7VM</a></p>
	    <p class="fl_right">W7VM <a href="http://www.w7vm.com/" title="Developer Application Mobile">Developer Application Mobile</a></p>
	  </footer>
	</div>
</h:form> 
</h:body>
</html>